package 二叉树;

import java.text.DateFormat;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * TODO
 *
 * @Description
 * @Author Lx
 * @Date 2024/7/5 10:32
 **/
public class test {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        Callable<Integer> callable = new Callable<>() {
            @Override
            public Integer call() throws Exception {
                return Integer.valueOf(1);
            }
        };

        FutureTask<Integer> task = new FutureTask<>(callable);
        Thread thread=new Thread(task);

        thread.run();
        LocalDateTime begin = LocalDateTime.now();
        Integer integer = task.get();
        Thread.sleep(1000);//睡1000ms
        LocalDateTime end=LocalDateTime.now();


        Duration duration=Duration.between(begin,end);
        System.out.println(integer+":"+duration.toString());
    }
}
